<?php

namespace App\Models;

class HousingsComment extends Model
{
    protected $fillable = [
        'field_name',
    ];
//    protected $table = 'enter_log';

    protected $table = 'housings_comment';
    protected $commentType = [1=>'很棒',2=>'不错',3=>'一般',4=>'较差',5=>'很糟糕'];
    public function user()
    {
        return $this->hasOne(AppUser::class,'id','user_id')->select('id','real_name','phone_number');
    }
    public function housingsorder()
    {
        return $this->hasOne(HousingsOrder::class,'id','housings_order_id')->select('sn','id','ota_sn');
    }

    public function housings()
    {
        return $this->hasOne(Housings::class,'id','housings_id')->select('housings_num','id','hou_address');
    }

    public function getCommentTypeAttribute($value)
    {
        return isset($this->commentType[$value]) ? $this->commentType[$value] : reset($this->commentType);
    }

}
